#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<unordered_set>
using namespace std;

class Solution{
    public:
    vector<string> ans1(vector<int>& nums){
        vector<vector<int>> arr;
        int p1 = 1, p2 = 0;
        while(p2 < nums.size()){
            while(p1 < nums.size()){
                if(nums[p1-1]+1 != nums[p1]){
                    break;
                }
                p1++;
            }
            if(p2 < p1-1){
                arr.push_back({nums[p2], nums[p1-1]});
            }else{
                arr.push_back({nums[p1-1]});
            }
            p2 = p1;
            p1++;
        }
        vector<string> ret;
        for(int i = 0; i != arr.size(); i++){
            if(arr[i].size() == 2){
                ret.push_back(to_string(arr[i][0]) + "->" + to_string(arr[i][1]));
            }else{
                ret.push_back(to_string(arr[i][0]));
            }
        }
        return ret;
    }
    

};

void test1(){
    Solution s;
    vector<int> nums = {0,1,2,4,5,7};
    vector<string> ret = s.ans1(nums);
    for(int i = 0; i != ret.size(); i++){
        cout << ret[i] << endl;
    }
    cout << "------------------------" << endl;
}

void test2(){
    Solution s;
    vector<int> nums = {0,2,3,4,6,8,9};
    vector<string> ret = s.ans1(nums);
    for(int i = 0; i != ret.size(); i++){
        cout << ret[i] << endl;
    }
    cout << "------------------------" << endl;
}


int main(void){
    test1();
    test2();

    return 0;
}